package org.anti996.lms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.anti996.lms.model.Driver;
import org.anti996.lms.model.Truck;
import org.anti996.lms.mapper.TruckMapper;
import org.anti996.lms.model.Warehouse;
import org.anti996.lms.service.TruckService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 货车表 服务实现类
 * </p>
 *
 * @author The Anti996 Authors
 * @since 2022-07-15
 */
@Service
public class TruckServiceImpl extends ServiceImpl<TruckMapper, Truck> implements TruckService {

    @Override//根据仓库编号获取车
    public Truck gettIdBywId(Integer wId) {
        QueryWrapper<Truck> wrapper = new QueryWrapper<>();
        wrapper.eq("state",0);
        wrapper.eq("w_id",wId);
        List<Truck> trucks=baseMapper.selectList(wrapper);
        Truck truck=trucks.get(0);
        truck.setState(1);
        return truck;
    }

    @Override//根据收发仓库判断是否有可用司机
    public boolean isexist(Integer widfrom){
        QueryWrapper<Truck> wrapper = new QueryWrapper<>();
        wrapper.eq("state",0);
        wrapper.eq("w_id",widfrom);
        return baseMapper.exists(wrapper);
    }
}
